/**
 * 2016年8月8日
 */
package controllers.web;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import controllers.BaseController;
import service.web.WebContentService;
import util.Page;
import util.PageUtil;
import webCrawler.BasicCrawler;
import webCrawler.WebContentController;

/**
 * @author Alex
 *
 */
@Controller
@RequestMapping("web")
public class WebCrawlerController  extends BaseController{
	@Autowired WebContentController controller;
	@Autowired WebContentService wcs;
	@RequestMapping("/crawl.do")
	@ResponseBody
	public String crawl(HttpServletRequest req, HttpServletResponse res) {
		controller.addSeed("http://news.163.com/");
		controller.start(BasicCrawler.class,2, false);
		
		return jsonDump(SUCCESS);
	}
	@RequestMapping("/getWebContent.do")
	@ResponseBody
	public String getWebContent(HttpServletRequest req, HttpServletResponse res) {
		//String page = req.getParameter("page");
		//Page p = PageUtil.createPage(10, 1000, Integer.parseInt(page));
		Page p = PageUtil.createPage(10, 1000,1);
		return jsonDump(wcs.selectWebContentByDate(p));
	}
	
	
	
	
}
